package com.guyaogg.gulimall.product.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.guyaogg.common.valid.annotation.ListValue;
import com.guyaogg.common.valid.annotation.UpdateName;
import com.guyaogg.common.valid.group.AddGroup;
import com.guyaogg.common.valid.group.UpdateGroup;
import lombok.Data;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.io.Serializable;
import java.util.List;

/**
 * 商品三级分类
 * 
 * @author guyao
 * @email 3039744913@qq.com
 * @date 2021-10-08 15:51:59
 */
@Data
@TableName("pms_category")
public class CategoryEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 分类 id
	 */
	@NotNull(message = "修改必须指定分类 id ",groups = UpdateGroup.class)
	@Null(message = "新增不能指定分类 id ",groups = AddGroup.class)
	@TableId
	private Long catId;
	/**
	 * 分类名称
	 */
	@UpdateName(message = "分类名称不能修改为空",groups = UpdateGroup.class)
	@NotBlank(message = "分类名称不能为空",groups = AddGroup.class)
	private String name;
	/**
	 * 父分类id
	 */
	private Long parentCid;
	/**
	 * 层级
	 */
	private Integer catLevel;
	/**
	 * 是否显示[0-不显示，1显示]
	 */
	@TableLogic
	@NotNull(message = "显示状态不能为空",groups = AddGroup.class)
	@ListValue(value={0,1},message = "显示状态必须为 0 或 1",groups = {UpdateGroup.class,AddGroup.class})
	private Integer showStatus;
	/**
	 * 排序
	 */
	@NotNull(message = "排序字段不能为空",groups = AddGroup.class)
	@Min(value = 0,message = "排序字段必须大于等于零",groups = {UpdateGroup.class,AddGroup.class})
	private Integer sort;
	/**
	 * 图标地址
	 */
	private String icon;
	/**
	 * 计量单位
	 */
	private String productUnit;
	/**
	 * 商品数量
	 */
	private Integer productCount;

	/**
	 * 数据子分类
	 * # @TableField(exist = false) 表中不存在
	 */
	@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
	@TableField(exist = false)
	private List<CategoryEntity> children;

}
